package com.tencent.sr.iris.activity.interfaces.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tencent.sr.rmall.common.exception.TMallBizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 */
@AllArgsConstructor
@Getter
public enum ActivityIdEnum {

    //月月领
    MONTH_GIFT("MONTH_GIFT", "月月领"),

    //注册有礼
    REGIST_GIFT("REGIST_GIFT", "注册有礼"),

    //邀请有礼
    INVITE_GIFT("INVITE_GIFT", "普通邀请有礼"),
    SPECIAL_INVITE_REWARD("SPECIAL_INVITE_REWARD", "特邀邀请有礼"),

    //升级有礼(培育奖)
    LEVEL_UP_FOSTER_GIFT("LEVEL_UP_FOSTER_GIFT", "升级有礼(培育奖)"),

    //升级有礼(晋升奖)
    LEVEL_UP_PROMO_GIFT("LEVEL_UP_PROMO_GIFT", "升级有礼(晋升奖)"),

    // 辅导津贴
    GUIDE_ALLOWANCE("GUIDE_ALLOWANCE", "辅导津贴")
    ;

    @JsonValue
    private final String code;
    private final String desc;

    @JsonCreator
    public static ActivityIdEnum jsonCreator(String code) {
        ActivityIdEnum activityIdEnum = getByCode(code);
        if (activityIdEnum == null) {
            throw new TMallBizException("活动id错误");
        }
        return activityIdEnum;
    }

    public static ActivityIdEnum getByCode(String code) {
        for (ActivityIdEnum staff : ActivityIdEnum.values()) {
            if (staff.getCode().equals(code)) {
                return staff;
            }
        }

        return null;
    }
}
